<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动与定位-绝对定位的盒子垂直居中</title>
    <style>
        /* 使蓝色方块位于红色方块正中间 */
        .per {
            width: 300px;
            height: 300px;
            background: red;
            position: relative;
            margin-left: 200px;
            margin-top: 200px;
        }

        .son {
            width: 100px;
            height: 100px;
            background: blue;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -50px;
            margin-left: -50px;


        }
    </style>
</head>

<body>
    <div class="per">
        <div class="son">
            aaassdddddddddddddddddd
        </div>
    </div>
</body>

</html>